{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Requirement already satisfied: jieba in c:\\programdata\\anaconda3\\lib\\site-packages (0.42.1)\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "twisted 18.7.0 requires PyHamcrest>=1.9.0, which is not installed.\n",
      "You are using pip version 10.0.1, however version 24.0 is available.\n",
      "You should consider upgrading via the 'python -m pip install --upgrade pip' command.\n"
     ]
    }
   ],
   "source": [
    "!pip install jieba"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "def get_weight(sentences,keywords):\n",
    "    for sentence in sentences:\n",
    "        mark=sentence[\"pos\"][\"mark\"]\n",
    "        weightPos=0\n",
    "        if\"FIRSTSECTTON\"in mark:\n",
    "            weightPos=weightPos+2\n",
    "        if\"FIRSTSENTENCE\"in mark:\n",
    "            weightPos=weightPos+2\n",
    "        if\"LASTSENTENCE\"in mark:\n",
    "            weightPos=weightPos+1\n",
    "        sentence[\"weightPos\"]=weightPos\n",
    "    index=[\"冬梦\",\"飞跃\"]\n",
    "    for sentence in sentences:\n",
    "        sentence[\"weightCueWords\"]=0\n",
    "        sentence[\"weightKeywords\"]=0\n",
    "    for i in index:\n",
    "        for sentence in sentences:\n",
    "            if sentence[\"text\"].find(i)>0:\n",
    "               sentence[\"weightCueWords\"]=1\n",
    "    for keyword in keywords:\n",
    "        for sentence in sentences:\n",
    "            if sentence[\"text\"].find(keyword)>=0:\n",
    "                sentence[\"weightKeywords\"]=sentence[\"weightKeywords\"]+1\n",
    "    weight=[]\n",
    "    for sentence in sentences:\n",
    "        sentence[\"weight\"]=sentence[\"weightPos\"] +2 *sentence[\"weightCueWords\"]+sentence[\"weightKeywords\"]\n",
    "        weight.append(sentence[\"weight\"])\n",
    "return weight"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.0"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
